#!/bin/bash

# 检查 JAVA_HOME 是否已设置
if [ -z "$JAVA_HOME" ]; then
    echo "The JAVA_HOME environment variable is not defined correctly."
    exit 1
fi

# 打印 JAVA_HOME 和 Java 版本信息
echo "JAVA_HOME is set to $JAVA_HOME"
java -version

# 执行 Maven 命令并将输出重定向到 build.log
mvn clean install -e -U -Dmaven.test.skip=true > build.log 2>&1 && echo "已完成" >> build.log &

# 获取后台进程的 PID
PID=$!

# 输出提示信息
echo "Maven build is running in the background. PID: $PID"
echo "Check build.log for details."
